<html>
<head><meta charset="utf-8"><title>lowering · z-archived-t-compiler/wg-rls-2.0/chalk · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/index.html">z-archived-t-compiler/wg-rls-2.0/chalk</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html">lowering</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160717808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160717808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160717808">(Mar 13 2019 at 19:00)</a>:</h4>
<p>so <span class="user-mention" data-user-id="131694">@scalexm</span>, I've not gotten as far on this as I liked, because I was running late on other things, but I'm looking a bit</p>



<a name="160717822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160717822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160717822">(Mar 13 2019 at 19:00)</a>:</h4>
<p>so far I mostly added some comments here and there ;)</p>



<a name="160717989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160717989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160717989">(Mar 13 2019 at 19:03)</a>:</h4>
<p>oh dear, we should also bump up to a recent version of salsa</p>



<a name="160717993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160717993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160717993">(Mar 13 2019 at 19:03)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> where did you write those comments actually?</p>



<a name="160718049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160718049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160718049">(Mar 13 2019 at 19:04)</a>:</h4>
<p>see the most recent commit in <a href="https://github.com/nikomatsakis/chalk-ndm/tree/query-driven-lowering" target="_blank" title="https://github.com/nikomatsakis/chalk-ndm/tree/query-driven-lowering">https://github.com/nikomatsakis/chalk-ndm/tree/query-driven-lowering</a></p>



<a name="160718774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160718774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160718774">(Mar 13 2019 at 19:12)</a>:</h4>
<p>so <span class="user-mention" data-user-id="116883">@tmandry</span> already set up a <a href="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/query.rs#L13-L50" target="_blank" title="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/query.rs#L13-L50">number of queries here</a></p>



<a name="160718942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160718942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160718942">(Mar 13 2019 at 19:14)</a>:</h4>
<ul>
<li><code>program_ir</code> -- produces the equivalent of the HIR</li>
<li><code>environment</code> -- converts those rules into logic</li>
<li><code>lowered_program</code> -- a version of the rust-ir where we have specialization priorities</li>
<li><code>checked_program</code> -- same, but we apply coherence checks</li>
</ul>



<a name="160718959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160718959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160718959">(Mar 13 2019 at 19:15)</a>:</h4>
<p>this setup isn't quite right since, in the future, I would expect specialization priorities to be needed in order to compute the lowered rules</p>



<a name="160718980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160718980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160718980">(Mar 13 2019 at 19:15)</a>:</h4>
<p>the actual lowering into IR is done in <a href="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/rules.rs#L12" target="_blank" title="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/rules.rs#L12">the <code>environment</code> method</a></p>



<a name="160719121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719121">(Mar 13 2019 at 19:17)</a>:</h4>
<p>as an aside, I suspect we can remove the <a href="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/rules.rs#L39-L41" target="_blank" title="https://github.com/nikomatsakis/chalk-ndm/blob/7fc671c0436e73582f84f0ca5575f2b3d44d4375/src/rules.rs#L39-L41">logic here around the derefs trait for now</a></p>



<a name="160719137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719137">(Mar 13 2019 at 19:17)</a>:</h4>
<p>we might want it later, once we make some progress on encoding coercions, but...</p>



<a name="160719240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719240">(Mar 13 2019 at 19:18)</a>:</h4>
<p>I'm ok for removing the logic around derefs trait</p>



<a name="160719261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719261">(Mar 13 2019 at 19:19)</a>:</h4>
<p>we may probably want to also do that for unselected projections, which are broken atm</p>



<a name="160719264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719264">(Mar 13 2019 at 19:19)</a>:</h4>
<p>so, I think we probably want <code>environment</code> to take some kind of indication of which rules it is generating</p>



<a name="160719279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719279">(Mar 13 2019 at 19:19)</a>:</h4>
<blockquote>
<p>we may probably want to do that for unselected projections, which are broken atm</p>
</blockquote>
<p>do what?</p>



<a name="160719282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719282">(Mar 13 2019 at 19:19)</a>:</h4>
<p>remove some logic around them :)</p>



<a name="160719285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719285">(Mar 13 2019 at 19:19)</a>:</h4>
<p>e.g., maybe it should be <code>environment(TraitId)</code></p>



<a name="160719298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719298">(Mar 13 2019 at 19:19)</a>:</h4>
<blockquote>
<p>remove some logic around them :)</p>
</blockquote>
<p>ah :) yeah, perhaps. I think we're going to want that concept pretty soon but it'd be ok to add it back</p>



<a name="160719353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719353">(Mar 13 2019 at 19:20)</a>:</h4>
<p>implied bounds make things a <em>bit</em> complicated</p>



<a name="160719361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719361">(Mar 13 2019 at 19:20)</a>:</h4>
<p>well, I guess this is not dissimilar from the logic we had in rustc</p>



<a name="160719489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719489">(Mar 13 2019 at 19:22)</a>:</h4>
<p>ah yeah so probably <code>environment(ItemId)</code> or something then</p>



<a name="160719502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719502">(Mar 13 2019 at 19:22)</a>:</h4>
<p>so that we cover impls as well etc?</p>



<a name="160719569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719569">(Mar 13 2019 at 19:23)</a>:</h4>
<p>then we can indeed have a similar setup to what is done in rustc, with some <code>program_clauses_for_...</code> (including for <code>environment</code>)</p>



<a name="160719657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719657">(Mar 13 2019 at 19:24)</a>:</h4>
<p>yeah, sorry, got distracted.</p>



<a name="160719679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719679">(Mar 13 2019 at 19:24)</a>:</h4>
<p>I mean the thing is, we definitely need to be able to ask "give me the rules that can prove <code>Implemented[SomeTrait]</code>"</p>



<a name="160719712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719712">(Mar 13 2019 at 19:25)</a>:</h4>
<p>i.e., specialization will need it</p>



<a name="160719719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719719">(Mar 13 2019 at 19:25)</a>:</h4>
<p>well just everything</p>



<a name="160719743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719743">(Mar 13 2019 at 19:25)</a>:</h4>
<p>what I think we want then is that this would not be a method on a <code>rust_ir::Program</code></p>



<a name="160719754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719754">(Mar 13 2019 at 19:26)</a>:</h4>
<p>but rather a query on the salsa database</p>



<a name="160719804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719804">(Mar 13 2019 at 19:26)</a>:</h4>
<p>and it would invoke other queries to extract out the data it needs from the rust-ir</p>



<a name="160719846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719846">(Mar 13 2019 at 19:26)</a>:</h4>
<p>ah, right, I remember now</p>



<a name="160719861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719861">(Mar 13 2019 at 19:26)</a>:</h4>
<p>for implied bounds, the key point is that we only need those rules when given <code>FromEnv</code>,</p>



<a name="160719875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719875">(Mar 13 2019 at 19:26)</a>:</h4>
<p>and we can kind of derive it by going <strong>forward</strong> from what's in the environment, right?</p>



<a name="160719891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719891">(Mar 13 2019 at 19:27)</a>:</h4>
<p>right, that's what is done in the <code>program_clauses_for_environment</code> query in rustc</p>



<a name="160719900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719900">(Mar 13 2019 at 19:27)</a>:</h4>
<p>yeah, I remember thinking about this, I just forgot the answer that we found :)</p>



<a name="160719909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719909">(Mar 13 2019 at 19:27)</a>:</h4>
<p>ok, so it seems like we kind of want to move a variant (hopefully nicer) of that logic from rustc into chalk</p>



<a name="160719915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160719915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160719915">(Mar 13 2019 at 19:27)</a>:</h4>
<p>makes sense</p>



<a name="160720151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720151">(Mar 13 2019 at 19:30)</a>:</h4>
<p>so if I understand well, regarding RLS integration, these queries in chalk which e.g. compute an environment would call some other queries e.g. <code>lower_type</code> which would compute the rust-ir representation of a given type, but these <code>lower</code> queries may be implemented in another crate like in the RLS crate?</p>



<a name="160720188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720188">(Mar 13 2019 at 19:31)</a>:</h4>
<p>right</p>



<a name="160720192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720192">(Mar 13 2019 at 19:31)</a>:</h4>
<p>so I think the steps here would be as follows</p>



<a name="160720200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720200">(Mar 13 2019 at 19:31)</a>:</h4>
<p>first, we make the queries in question, all in the one crate (<code>chalk</code>)</p>



<a name="160720210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720210">(Mar 13 2019 at 19:31)</a>:</h4>
<p>then we can extract the lowering queries into another crate (let's call it <code>chalk_lower</code>)</p>



<a name="160720217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720217">(Mar 13 2019 at 19:31)</a>:</h4>
<p>but leave behind the ones that provide the rust-ir</p>



<a name="160720293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720293">(Mar 13 2019 at 19:32)</a>:</h4>
<p>so if you have layers, it's like:</p>
<ul>
<li>lowering queries (in <code>chalk_lower</code>)</li>
<li>(shim)</li>
<li>rust-ir providing queries (in <code>chalk</code>)</li>
</ul>



<a name="160720300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720300">(Mar 13 2019 at 19:32)</a>:</h4>
<p>the "shim" part would be a trait that we define</p>



<a name="160720318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720318">(Mar 13 2019 at 19:32)</a>:</h4>
<p>i.e.,</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">RustIrShim</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">rust_ir_struct</span><span class="p">(</span><span class="n">Id</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">rust_ir</span>::<span class="n">StructDatum</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="160720355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720355">(Mar 13 2019 at 19:33)</a>:</h4>
<p>we can then implement this trait like so in the <code>chalk</code> crate</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="w"> </span><span class="n">RustIrShim</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">ChalkDatabase</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">rust_ir_struct</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">id</span>: <span class="nc">Id</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">StructDatum</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">.</span><span class="n">rust_ir_query</span><span class="p">(</span><span class="n">id</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="160720364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720364">(Mar 13 2019 at 19:33)</a>:</h4>
<p>not sure if that makes sense, not sure how familiar you are with salsa's setup</p>



<a name="160720382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720382">(Mar 13 2019 at 19:33)</a>:</h4>
<p>I'm not that familiar but that makes sense</p>



<a name="160720388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720388">(Mar 13 2019 at 19:34)</a>:</h4>
<p>should be straightforward</p>



<a name="160720431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720431">(Mar 13 2019 at 19:34)</a>:</h4>
<p>once we get the queries setup correctly</p>



<a name="160720442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720442">(Mar 13 2019 at 19:34)</a>:</h4>
<p>which is cool, btw, I'm happy with how that part of salsa's design is working out :)</p>



<a name="160720471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720471">(Mar 13 2019 at 19:34)</a>:</h4>
<p>for some reason, however, upgrading to salsa 0.10.0 is not building for me</p>



<a name="160720912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720912">(Mar 13 2019 at 19:40)</a>:</h4>
<p>in <code>rust_ir/lowering.rs</code>, we use that <code>Env&lt;'k&gt;</code> to resolve things like type parameters</p>



<a name="160720920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160720920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160720920">(Mar 13 2019 at 19:41)</a>:</h4>
<p>so this would now be an input to the rust-ir queries I guess</p>



<a name="160721205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/160721205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#160721205">(Mar 13 2019 at 19:46)</a>:</h4>
<p>mmh we could actually have two levels: the top level-query for example <code>lower_impl</code>  which would start with an empty env, and then which would call some lowering functions without passing through the salsa database, building that <code>Env&lt;'k&gt;</code> along the way</p>



<a name="161013945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/161013945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#161013945">(Mar 17 2019 at 20:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> it would be cool if we were not using <code>String</code> as an error type in the salsa queries; I'm currently trying to convert all error types to real ones (be it custom <code>enum</code> or <code>struct</code>) that do implement <code>Clone</code></p>



<a name="161014639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/161014639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#161014639">(Mar 17 2019 at 20:59)</a>:</h4>
<p><span class="user-mention" data-user-id="131694">@scalexm</span> as shameless self-promotion, may I suggest giving my new <a href="https://crates.io/crates/snafu" target="_blank" title="https://crates.io/crates/snafu">SNAFU crate</a> a whirl? <span aria-label="angel" class="emoji emoji-1f47c" role="img" title="angel">:angel:</span></p>



<a name="161051761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering/near/161051761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scalexm <a href="https://rust-lang.github.io/zulip_archive/stream/191167-z-archived-t-compiler/wg-rls-2.0/chalk/topic/lowering.html#161051761">(Mar 18 2019 at 12:13)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> lol I’ll give it a try</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>